package modifier.tile;

import board.Tile;
import character.MyCharacter;
import game.DataStore;
import game.GameState;
import game.StateSwitcher;
import modifier.TickingModifier;

public abstract class TileModifier extends TickingModifier {
    protected Tile tile;
    
    @Deprecated
    protected TileModifier() {}

    public TileModifier(MyCharacter owner, int duration) {
        super(owner, duration);
    }
    
    @Override
    protected void apply() {
        if(StateSwitcher.getGameState() == GameState.COMBAT)
            DataStore.combatAppState.addCombatActorAtCurrentInitiative(tile);
    }
    
    @Override
    protected void tick() {}
    
    @Override
    protected void completeNaturally() {
        if(StateSwitcher.getGameState() == GameState.COMBAT)
            DataStore.combatAppState.removeCombatActor(tile);
    }

    @Override
    protected void abort() {
        if(StateSwitcher.getGameState() == GameState.COMBAT)
            DataStore.combatAppState.removeCombatActor(tile);
    }
    
    public abstract TileModifier cloneForTile(Tile tile);
    
    protected void cloneMeForTile(TileModifier tileModifier, Tile tile) {
        super.cloneMe(tileModifier);
        tileModifier.tile = tile;
    }
}
